var http = require('http')

var url = 'http://thirdwx.qlogo.cn/mmopen/BEMV4WOAicktAAllnv9FdJFSU7QYVibMU62ctg7Ie5HiaCuDVCyiapibwrs48N97yrzLel03FvOUqAHEZGfBY5tCdnuHKEg4YvZSC/132' //一张网络图片
var url = 'https://i0.hdslb.com/bfs/vc/75ec2d45ce8c942a1f7379d4641171da4d90ab0d.png@1c.webp' //一张网络图片

http.get(url, res => {
  var chunks = []
  var size = 0
  res.on('data', chunk => {
    chunks.push(chunk)
    size += chunk.length //累加缓冲数据的长度
  })
  res.on('end', err => {
    var data = Buffer.concat(chunks, size)
    var base64Img = data.toString('base64')
    console.log(`data:image/pngbase64,${base64Img}`)
  })
})